// 官网示例，测试未通过
// https://developer.atlassian.com/cloud/jira/platform/rest/v2/#api-api-2-version-post


var request = require('request');

var bodyData = {
    "description": "2.4.4.2版本啊",
    "name": "2.4.4.2",
    "projectId": 10119
};

var options = {
    method: 'POST',
    url: 'http://jira.in.zhihu.com/rest/api/2/project/QA/version',
    auth: {
        'user': 'xxx',
        'pass': 'xxx',
        'sendImmediately': false
    },
    headers: {
        'Accept': 'application/json',
        'Content-Type': 'application/json'
    },
    body: {
        "name": "4.24.2", // 必填
        "projectId": 10119 // 必填
    }
};

// 根据官方给的例子改写，但是报错抛异常：Error: Error: Argument error, options.body
// 参考：
// https://developer.atlassian.com/cloud/jira/platform/rest/#api-api-2-version-post
// https://www.npmjs.com/package/request#custom-http-headers
// 暂时未解决request方式的post请求修改Project的版本号
request(options, function(error, response, body) {
    if (error) throw new Error(error);
    console.log(
        'Response: ' + response.statusCode + ' ' + response.statusMessage
    );
    console.log(body);
});